<template>
	<view>
		<my-address></my-address>
		<!-- 购物车商品标题 -->
		<view class="cart-title">
			<!-- 购物车左侧图标 -->
			<uni-icons type='shop' size="18"></uni-icons>
			<!-- 文本 -->
			<text class="cart-title-text">购物车</text>
		</view>

		<!-- 商品列表 -->
		<uni-swipe-action>
			<block v-for="(item,index) in cart" :key='index'>
				<uni-swipe-action-item :right-options='options' @click="deleteGoods(item)">
				<my-goods :show-radio='true' :goods='item' @changeRadio="changeRadio" @changeNum='cahngeNum'
					:show-num='true'></my-goods></uni-swipe-action-item>
			</block>
		</uni-swipe-action>
		<my-settle></my-settle>
	</view>
</template>

<script>
	import TabBarBadge from '../../mixins/tabbar-badge.js'
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		mixins: [TabBarBadge],
		computed: {
			...mapState('my_cart', ['cart'])
		},
		data() {
			return {
options:[
	{
		text:'删除',
		style:{
			backgroundColor:"#c00000"
		}
	}
]
			};
		},
		methods: {
			...mapMutations('my_cart', ['updateState','updateGoodsCount','updateDeleteGoods']),
			changeRadio(goods) {
				this.updateState(goods)
			},
			cahngeNum(goods) {
				this.updateGoodsCount(goods)
			},
			deleteGoods(goods){
				this.updateDeleteGoods(goods)
			}
		}
	}
</script>

<style lang="scss">
	.cart-title {
		display: flex;
		height: 40px;
		align-items: center;
		font-size: 14px;
		border-bottom: 1px solid #efefef;
		padding-left: 5px;

		.cart-title-text {
			margin-left: 10px;
		}
	}
</style>
